/*
 * Created by: HuyNVK
 * This file defines some js function to help submitting form to server.
 */

/**
 * Redirect when click on top-navigation's items.
 */
function redirect(frm, pageName) {
    frm.pageName.value = pageName;
    //frm.subPage.value = "";
    //frm.section.value = "";
    
    frm.submit();
}

/**
 * Redirect when click on left-navigation's items.
 */
function redirect(frm, pageName, subPage) {
    frm.pageName.value = pageName;
    frm.subPage.value = subPage;
    //frm.section.value = "";
    
    frm.submit();
}

/**
 * Redirect to a section in a subPage.
 */
function redirect(frm, pageName, subPage, section) {
    frm.pageName.value = pageName;
    frm.subPage.value = subPage;
    frm.section.value = section;
    
    frm.submit();
}

/**
 * Commit an action.
 */
function doAction(frm, pageName, subPage, action) {
    frm.pageName.value = pageName;
    frm.subPage.value = subPage;
    frm.action.value = action;
    
    frm.submit();
}

/**
 * Commit an action from section.
 */
function doAction(frm, pageName, subPage, section, action) {
    frm.pageName.value = pageName;
    frm.subPage.value = subPage;
    frm.setion.value = section;
    frm.action.value = action;
    
    frm.submit();
}

/**
 * Commit an action with a specific item.
 */
function doAction(frm, pageName, subPage, action, id) {
    frm.pageName.value = pageName;
    frm.subPage.value = subPage;
    frm.action.value = action;
    frm.selectedItemID.value = id;
    
    frm.submit();
}

/**
 * Commit an action with a specific item.
 */
function doAction(frm, pageName, subPage, section, action, id) {
    frm.pageName.value = pageName;
    frm.subPage.value = subPage;
    frm.section.value = section;
    frm.action.value = action;
    frm.selectedItemID.value = id;
    
    frm.submit();
}

function testCharacters(frm) {
    var test = frm.description.value;
    alert(test);
}